package com.cy.web;

import com.alibaba.fastjson.JSONArray;

import com.cy.Service.ChatService;
import com.cy.bean.Fronthost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/admin")
public class ChatController {
    @Autowired
    private ChatService chatService;

    @RequestMapping("/login")
    public String login(){
        return "adminlogin";
    }

    @RequestMapping(value = "/adminLogin",produces = "text/html;charset=utf-8")
    public @ResponseBody
    String adminLogin(HttpServletRequest request){
        String uname = request.getParameter("uname");
        String upwd = request.getParameter("upwd");
        System.out.println("11++++++++"+upwd);
        Fronthost fronthost = chatService.adminLogin(uname,upwd);
        String obj = JSONArray.toJSONString(fronthost);
        return obj;
    }
    @RequestMapping("/main")
    public String main(){
        return "chat";
    }
}
